'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _class, _class3, _class5;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _radium = require('radium');

var _radium2 = _interopRequireDefault(_radium);

var _objectAssign = require('object-assign');

var _objectAssign2 = _interopRequireDefault(_objectAssign);

var _lightbiFrontUtils = require('lightbi-front-utils');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var IndexHeaderLeftItem = (0, _radium2.default)(_class = function (_React$Component) {
  _inherits(IndexHeaderLeftItem, _React$Component);

  function IndexHeaderLeftItem(props) {
    _classCallCheck(this, IndexHeaderLeftItem);

    var _this = _possibleConstructorReturn(this, (IndexHeaderLeftItem.__proto__ || Object.getPrototypeOf(IndexHeaderLeftItem)).call(this, props));

    _this.goto = _this.goto.bind(_this);
    _this.onMouseOver = _this.onMouseOver.bind(_this);
    _this.onMouseOut = _this.onMouseOut.bind(_this);
    return _this;
  }

  _createClass(IndexHeaderLeftItem, [{
    key: 'goto',
    value: function goto() {
      if (this.props.item == '首页') window.location.href = _lightbiFrontUtils.IN_DEPLOY_URI + '/';else if (this.props.item == '市场') window.location.href = _lightbiFrontUtils.IN_DEPLOY_URI + '/market';
    }
  }, {
    key: 'onMouseOver',
    value: function onMouseOver() {
      this.setState({ isOver: true });
    }
  }, {
    key: 'onMouseOut',
    value: function onMouseOut() {
      this.setState({ isOver: false });
    }
  }, {
    key: 'render',
    value: function render() {
      var style = { minWidth: '130px', textAlign: 'center', cursor: 'pointer', borderTop: '2px solid #fff', '@media screen and (max-width: 992px)': { minWidth: '60px' } };
      if (this.props.item == this.props.selectedItem) style = (0, _objectAssign2.default)(style, { color: '#3a8fc8' });
      if (!!this.state.isOver) style = (0, _objectAssign2.default)(style, { borderTop: '2px solid rgb(91, 77, 145)' });

      return _react2.default.createElement(
        'div',
        { className: 'pull-left', style: style, onClick: this.goto, onMouseOver: this.onMouseOver, onMouseOut: this.onMouseOut },
        this.props.item
      );
    }
  }]);

  return IndexHeaderLeftItem;
}(_react2.default.Component)) || _class;

;

var IndexHeaderRightItem = (0, _radium2.default)(_class3 = function (_React$Component2) {
  _inherits(IndexHeaderRightItem, _React$Component2);

  function IndexHeaderRightItem(props) {
    _classCallCheck(this, IndexHeaderRightItem);

    var _this2 = _possibleConstructorReturn(this, (IndexHeaderRightItem.__proto__ || Object.getPrototypeOf(IndexHeaderRightItem)).call(this, props));

    _this2.goto = _this2.goto.bind(_this2);
    _this2.onMouseOver = _this2.onMouseOver.bind(_this2);
    _this2.onMouseOut = _this2.onMouseOut.bind(_this2);
    _this2.state = {};
    _this2.jumpUri = _this2.props.location.query['jumpUri'];
    return _this2;
  }

  _createClass(IndexHeaderRightItem, [{
    key: 'goto',
    value: function goto() {
      if (this.props.item == '注册') {
        if (this.jumpUri == null || this.jumpUri.length == 0) this.props.router.push(_lightbiFrontUtils.IN_DEPLOY_URI + '/entrance/register');else this.props.router.push(_lightbiFrontUtils.IN_DEPLOY_URI + '/entrance/register?jumpUri=' + this.jumpUri);
      } else if (this.props.item == '登录') {
        if (this.jumpUri == null || this.jumpUri.length == 0) this.props.router.push(_lightbiFrontUtils.IN_DEPLOY_URI + '/entrance/login');else this.props.router.push(_lightbiFrontUtils.IN_DEPLOY_URI + '/entrance/login?jumpUri=' + this.jumpUri);
      }
    }
  }, {
    key: 'onMouseOver',
    value: function onMouseOver() {
      this.setState({ isOver: true });
    }
  }, {
    key: 'onMouseOut',
    value: function onMouseOut() {
      this.setState({ isOver: false });
    }
  }, {
    key: 'render',
    value: function render() {
      var style = { minWidth: '130px', textAlign: 'center', borderTop: '2px solid #fff', cursor: 'pointer', '@media screen and (max-width: 992px)': { minWidth: '60px' } };
      if (this.props.item == this.props.selectedItem) style = (0, _objectAssign2.default)(style, { color: '#3a8fc8' });
      if (!!this.state.isOver) style = (0, _objectAssign2.default)(style, { borderTop: '2px solid rgb(91, 77, 145)' });

      return _react2.default.createElement(
        'div',
        { className: 'pull-right', style: style, onClick: this.goto, onMouseOver: this.onMouseOver, onMouseOut: this.onMouseOut },
        this.props.item
      );
    }
  }]);

  return IndexHeaderRightItem;
}(_react2.default.Component)) || _class3;

;

var IndexHeader = (0, _radium2.default)(_class5 = function (_React$Component3) {
  _inherits(IndexHeader, _React$Component3);

  function IndexHeader(props) {
    _classCallCheck(this, IndexHeader);

    var _this3 = _possibleConstructorReturn(this, (IndexHeader.__proto__ || Object.getPrototypeOf(IndexHeader)).call(this, props));

    _this3.gotoIndex = _this3.gotoIndex.bind(_this3);
    return _this3;
  }

  _createClass(IndexHeader, [{
    key: 'gotoIndex',
    value: function gotoIndex() {
      window.location.href = "/";
      //this.props.router.push(IN_DEPLOY_URI + "/");
    }
  }, {
    key: 'render',
    value: function render() {
      return _react2.default.createElement(
        'div',
        { style: { position: 'fixed', top: '0px', left: '0px', right: '0px', height: '60px', zIndex: '1', borderBottom: '1px solid #e6e6e6', backgroundColor: '#fff' } },
        _react2.default.createElement(
          'div',
          { className: 'row', style: { lineHeight: '60px', margin: '0px' } },
          process.env.CLIENT_ENV !== "nw" ? _react2.default.createElement(
            'div',
            { className: 'pull-left', style: { cursor: 'pointer', minWidth: '140px', color: '#48B0F7', '@media screen and (max-width: 992px)': { minWidth: '60px' } }, onClick: this.gotoIndex },
            _react2.default.createElement(
              'div',
              { 'class': 'row', style: { fontSize: '16px', height: '60px', margin: '0px' } },
              _react2.default.createElement(
                'div',
                { className: 'pull-left', style: { padding: '10px 5px 10px 10px', width: '165px', '@media screen and (max-width: 992px)': { display: 'none' } } },
                _react2.default.createElement('img', { src: '/img/logo.png' })
              ),
              _react2.default.createElement(
                'div',
                { className: 'pull-left', style: { padding: '10px', width: '110px', display: 'none', '@media screen and (max-width: 992px)': { display: 'block' } } },
                _react2.default.createElement('img', { src: '/img/logo.png' })
              )
            )
          ) : null,
          _react2.default.createElement(IndexHeaderLeftItem, { key: 'introduce', router: this.props.router, item: '\u9996\u9875', selectedItem: this.props.selectedItem }),
          _react2.default.createElement(IndexHeaderRightItem, { key: 'login', router: this.props.router, location: this.props.location, item: '\u767B\u5F55', selectedItem: this.props.selectedItem }),
          _react2.default.createElement(IndexHeaderRightItem, { key: 'register', router: this.props.router, location: this.props.location, item: '\u6CE8\u518C', selectedItem: this.props.selectedItem })
        )
      );
    }
  }]);

  return IndexHeader;
}(_react2.default.Component)) || _class5;

module.exports = IndexHeader;
//          <IndexHeaderLeftItem key="market" router={this.props.router} item="市场" selectedItem={this.props.selectedItem} />